package com.study.samsung.Service;

import com.study.samsung.Dao.OrderXqDao;
import com.study.samsung.Dao.OrdersDao;
import com.study.samsung.Entity.Address;
import com.study.samsung.Entity.OrderDetails;
import com.study.samsung.Entity.Orders;
import com.study.samsung.Entity.ShoppingCart;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;


public class OrderXqService {
    OrderXqDao dao = new OrderXqDao();
    OrdersDao dao1 = new OrdersDao();

    public List<OrderDetails> selectAll(){
        return dao.selectAll();
    }
    public Integer ordersinsert(String dxnumber, String dtime,String dstatus,String pay,Double dtotal,Integer uid,Integer aid){
        return  dao1.ordersinsert(dxnumber,dtime,dstatus,pay,dtotal,uid,aid);
    }

    public Integer ordersxqdel(Integer did){
        return dao.ordersxqdel(did);
    }

    public Integer ordersxqinsert(BigDecimal dxprice,int gnumber,int sxid,int did){
        return dao.ordersxqinsert(dxprice,gnumber,sxid,did);
    }

    public Integer ordersxqinserts(List<ShoppingCart> shoppingCarts,int did){

        for (int i = 0; i < shoppingCarts.size(); i++) {

            OrderDetails orderDetails = new OrderDetails(
                    null,
                    shoppingCarts.get(i).getDetail().getXprice(),
                    shoppingCarts.get(i).getGnum(),
                    shoppingCarts.get(i).getDetail().getSxid(),
                    did
            );
            dao.ordersxqinserts(orderDetails);
        }
        return shoppingCarts.size();
    }


}
